package com.cn.yang.servlet.mainPage;

import com.alibaba.fastjson.JSONObject;
import com.cn.yang.model.mainPage.HeadAndFootModel;
import com.cn.yang.service.MainPageService;
import com.cn.yang.service.impl.MainPageServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/back/mainPage/selectHeadFoot")
public class SelectHeadFootServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");


        MainPageService service = new MainPageServiceImpl();
        HeadAndFootModel headAndFootModel = service.selectHeadFoot();
        req.getSession().setAttribute("photo", headAndFootModel.getPhoto());
        JSONObject js = new JSONObject();
        js.put("model",headAndFootModel);
        resp.getWriter().println(js);
    }
}
